/*** 
 * @_______________#########_______________________ 
 * @______________############_____________________ 
 * @______________#############____________________ 
 * @_____________##__###########___________________ 
 * @____________###__######_#####__________________ 
 * @____________###_#######___####_________________ 
 * @___________###__##########_####________________ 
 * @__________####__###########_####_______________ 
 * @________#####___###########__#####_____________ 
 * @_______######___###_########___#####___________ 
 * @_______#####___###___########___######_________ 
 * @______######___###__###########___######_______ 
 * @_____######___####_##############__######______ 
 * @____#######__#####################_#######_____ 
 * @____#######__##############################____ 
 * @___#######__######_#################_#######___ 
 * @___#######__######_######_#########___######___ 
 * @___#######____##__######___######_____######___ 
 * @___#######________######____#####_____#####____ 
 * @____######________#####_____#####_____####_____ 
 * @_____#####________####______#####_____###______ 
 * @______#####______;###________###______#________ 
 * @________##_______####________####______________ 
 * @
 * @Author: ipk518 18163976442@163.com
 * @Date: 2024-06-19 10:31:14
 * @LastEditors: ipk518 18163976442@163.com
 * @LastEditTime: 2024-11-28 16:07:28
 * @FilePath: /etws-sxk2307V1.3/src/Service/queryProtocolTask.cpp
 * @Description: 
 * @************佛祖保佑************
 * @Copyright (c) 2024 by etws@quyujiang, All Rights Reserved. 
 */

#include "Server.h"


void Server::queryProtocolTask(Server *args)
{
	bool m_queryRes = false;
	pthread_setname_np(pthread_self(),"queryTask");
	while(args->isRunning)
	{
		if (sysRunStatus == SYS_INIT) {
			qlog_d("心跳参数查询解析线程等待运行..");
            std::this_thread::sleep_for(std::chrono::milliseconds(600));
            continue;
		}
		m_queryRes = args->queryPort->wait();
		if	(m_queryRes) {
			auto data = args->queryPort->take();
			if (data->cmdHead->DeviceType == t_query) {
				qlog_d("query dds:sourceType:%d,sourceNum:%d,cmdType:%d,cmdChildType:%d",
				data->cmdHead->source_DevType,data->cmdHead->source_DevNum,
				data->cmdHead->cmdType,data->cmdHead->cmdChildType);
				//刷新组件参数
				args->hrRefresh(data->cmdHead,data->dataEntity);
			}
			

			args->m_hrServer->keepAlive(*data);//心跳保活
			
			// data->cmdHead->dst_DevType = data->cmdHead->source_DevType;
			// data->cmdHead->dst_DevNum = data->cmdHead->source_DevNum;
			// data->cmdHead->source_DevType = CurDeviceType;
			// data->cmdHead->source_DevNum = ComponentNO;
			// args->m_queryDds->publish(data->cmdHead,data->dataEntity);
			args->queryPort->release(data);
		}
		m_queryRes = false;
	}
}